;Pirma programa

.model small
.stack 100h
.data
	help db 13,10,"Asemblerio uzduotis nr.5",13,10,"Parasykite programa, kuri ivesta simboliu eilute atspausdina atvirksciai ir atspausdina eilutes ilgi;",13,10,"Pvz.: ivedus abSDGasR turi atspausdinti RsaGDSba (ilgis 8)",13,10,"Paruose informatikos II kurso 3 grupes studentas,Zbignev Grinevic",13,10,"$"
	eil db 128, 128 dup ('$')
	msg db " ilgis=",'$'
	
.code
pradzia:
	mov 	ax,@data
	mov 	ds,ax
	mov	cl,0
	mov	bx,81h
ciklas:
	mov	ax,es:[bx]
	cmp	al,0dh
	je	nuskaitymas
	cmp	ax,3f2fh
	je	yra
	inc	bx
	jmp	ciklas
yra:
	mov 	ah,9
	lea 	dx,help   
	int	21h
	jmp 	galas	
	
nuskaitymas:
	mov 	ah,0ah
	lea 	dx,eil
	int 	21h

	mov 	ah,2
	mov 	dl,0ah
	int 	21h

	lea 	si,eil
	push	"$"

stekas:
	inc	si
	mov	ax,[si]	
	push	ax
	cmp	ah,0dh
	je	print
	inc	cl
	jmp 	stekas

print:
	
	mov	ah,2
	pop 	dx
	cmp 	dl,"$"
	je	kiek
	mov	dl,dh
	int 	21h
	jmp 	print
	 
kiek:
	mov 	ah,9
	mov 	dx,offset msg
	int	21h
	mov 	al,cl
	xor	cl,cl
	mov	cl,10
	push 	"$"
  stekas1:
	mov 	ah,0
	div	cl
	add	ah,30h
	push	ax
	cmp	al,0
	jne	stekas1
	push	" "
	
  spausdink:
	mov	ah,2
	pop	dx
	cmp	dl,"$"
	je	galas
	mov 	dl,dh
	int	21h
	jmp 	spausdink
	
		
galas:
	
	mov 	ah, 0				
	int	16h
	mov	ah, 4ch					
	int	21h	
end pradzia